﻿// ***********************************************************************
// Assembly         : NIMServerApi
// Author           : Walter
// Created          : 11-15-2016
//
// Last Modified By : Walter
// Last Modified On : 11-15-2016
// ***********************************************************************
// <copyright file="NIMCloud.cs" company="51iface">
//     Copyright 51iface©  2016
// </copyright>
// <summary></summary>
// ***********************************************************************

using System;
using NIMServerApi.Methods;

namespace NIMServerApi
{
    /// <summary>
    /// Class NIMCloud.
    /// </summary>
    public class NIMCloud
    {
        private readonly string appKey, appSecret;
        private string nonce;
        public const string NIMURI = "https://api.netease.im/nimserver";

        private UserMethod _user;
        private FriendMethod _friend;
        private MsgMethod _msg;

         #region 构造函数
        private NIMCloud()
        {
            appKey = System.Configuration.ConfigurationManager.AppSettings["nim_app_key"];
            appSecret = System.Configuration.ConfigurationManager.AppSettings["nim_app_secret"];

            _user = new UserMethod(appKey,appSecret);
            _friend = new FriendMethod(appKey,appSecret);
            _msg = new MsgMethod(appKey,appSecret);
        }
        #endregion

        /// <summary>
        /// Gets the instance.
        /// </summary>
        /// <returns>NIMHttpClient.</returns>
        public static NIMCloud GetInstance()
        {
            return NIMCloud.Nested.Instance;
        }

        

        /// <summary>
        /// 嵌套类处理多线程安全.
        /// </summary>
        class Nested
        {
            static Nested()
            {
            }
            internal static readonly NIMCloud Instance = new NIMCloud();
        }


        #region 属性

        public UserMethod User {
            get { return _user; }
        }

        public FriendMethod Friend {
            get
            {
                return _friend;
            }
        }

        public MsgMethod Msg
        {
            get
            {
                return _msg;
            }
        }

        #endregion
    }
}